<?php include("../components/autoload.php"); ?>
<?php include("../components/functions.php"); ?>
<?php include("../../components/connection.php"); ?>

<?php
	@header('Content-Type: text/html; charset=UTF-8'); 
	
	$league = new Liga($_GET['id']);
		
	$q = "DELETE FROM kolo WHERE liga = ". $league->id;
	if (mysql_query($q)) echo "Obrisana kola lige!<br />";
	
	$q = "DELETE FROM utakmica WHERE liga = ". $league->id;
	if (mysql_query($q)) echo "Obrisane utakmice lige!<br />";
	
	$qq = "SELECT id FROM utakmica WHERE liga = ". $league->id;
	$rq = mysql_query($qq);
	if (mysql_num_rows($rq)) {
		while ($nq = mysql_fetch_array($rq)) {
			$q = "DELETE FROM statistika WHERE mec = ". $nq['id'];
			if (mysql_query($q)) echo "Obrisana statistika sa utakmice!<br />";
		}
	}
	unset ($qq, $rq, $nq);
	
	$q = "DELETE FROM ucestvuje WHERE liga = ". $league->id;
	if (mysql_query($q)) echo "Obrisano ucesce ekipa!<br />";
	
	$q = "DELETE FROM liga WHERE id = ". $league->id;
	if (mysql_query($q)) echo "Obrisana Liga!<br />";
	
	unset($league);
	
?>